"""
回合制对战游戏
●创建角色:
名字、性别、血量、装备
●创建房间:
角色可加入房间
房间内的人可互打
房间上限2人
●战斗
血量默认100
正常被攻击- 10滴血
有防弹衣-5滴血
"""

import time#导入时间的包
import random
class Role:
    number = 0
    def __init__(self,name,sex,hp,equipment):
        self.name = name
        self.sex = sex
        self.hp = hp
        self.equipment = equipment
        Role.number += 1

    def tong(self,enemy):
        num1 = random.randint(0, 5)
        if self.equipment is None:
            enemy.hp-=(num1 * 10)
        else:
            enemy.hp-=(num1 * 5)

        info='%s捅了%s一刀'%(self.name, enemy.name)
        print (info)

    def kanren(self,enemy):
        num2 = random.randint(0, 5)
        if self.equipment is None:
            enemy.hp -= (num2 * 8)
        else:
            enemy.hp -= (num2 * 4)
        info = '%s砍了%s一刀' % (self.name, enemy.name)
        print (info)


    def __str__(self):
        return  '%s 还剩下 %s 的血量'%(self.name,self.hp)

# 进入房间的玩家数目
class Room():
    def Enter_room():
        if Role.number == 1:
            print("第一位玩家进入成功，等待另一位玩家的进入..")
        if Role.number == 2:
            print("两位玩家以成功进入房间，请准备开始战斗！")
        else:
            print("游戏人数不符合游戏设定，游戏进行失败..")
#创建两个小李,小文,实例化对象

li=Role('小李',"M",100,"None")
wen=Role('小文',"W",100,"clothes")
room = Room
room.Enter_room()
while True:
    if li.hp<=0 or wen.hp<=0:
        if li.hp>0:
            print("小李获胜")
        else:
            print("小文获胜")
        #满足条件,退出循环;
        break
    num1 = random.randint(0,1)
    if num1 == 0:
        li.tong(wen)#小李捅小文
    else:
        li.kanren(wen)
    print(wen)#打印对象状态
    print(li)
    print ('***********************')
    num1 = random.randint(0,1)
    if num1 == 0:
        wen.tong(li)#小李捅小文
    else:
        wen.kanren(li)
    print(wen)#打印对象状态
    print(li)
    print('************************')
    time.sleep(1)#循环一次暂停时间一秒

print ('对战结束')